package com.hj.bdqn.controller;

import com.hj.bdqn.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author 27435
 * @Date 2024/12/2615:44
 * @Version 1.0
 */

@Controller
public class HelloController {

    /**
     * 如果控制器想要返回json字符串  在方法上加一个@ResponseBody
     * @param user
     * @return
     */
    @RequestMapping(value = {"/login"}, produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String login(@RequestBody User user){
        System.out.println(user);
        return "{'code':'200','msg':'success'}";
    }

    /**
     * 返回页面
     * @return
     */
    @RequestMapping("/reg")
    public String reg(){
        // WEB-INF/pages/reg.jsp
        return "reg"; // 逻辑视图的名字
    }

}
